﻿using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using JaxDug.Controllers;
using JaxDug.Helpers;


namespace JaxDug
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode,
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
       

        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
            filters.Add(new LogonAuthorize());
        }

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.IgnoreRoute("{resource}.svc/{*pathInfo}");
            routes.IgnoreRoute("{resource}.css");
            routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
            
            //codecamp routes are handled in CodeCampAreaRegistration.cs

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional },// Parameter defaults
                new[] { "JaxDug.Controllers" } //http://haacked.com/archive/2010/01/12/ambiguous-controller-names.aspx
            );

            routes.MapRoute(
                "BookVote",
                "{controller}/{action}/{id}/{vote}",
                new { controller = "Book", action = "CastVote" });

            routes.MapRoute(
                "CreateBook",
                "{controller}/{action}/{isbn}",
                new { controller = "Book", action = "CreateBookForm" });
        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            // BootstrapContainer();
        }

       


        protected void Application_End()
        {
           
        }

        protected void Application_BeginRequest()
        {
        }

        protected void Application_EndRequest()
        {
        }

        public void Application_Error()
        {
           
        }
    }
}